package com.panopset.game.blackjack;

import java.io.IOException;
import java.util.List;

import com.panopset.compat.RezIO;
import com.panopset.game.DollarConverter;

/**
 * Blackjack game default configuration.
 *
 * @author Karl Dinwiddie
 *
 */
public class ConfigDft implements BlackjackConfig {

    public static final Integer DEFAULT_INITIAL_STAKE = 30000;
    public static final Integer DEFAULT_LARGE_BET = 2000;
    public static final Integer DEFAULT_TARGET_STAKE = 0;
    public static final Integer DEFAULT_INITIAL_WAGER = 500;
    private int seats = 1;
    private int decks = 1;
    private boolean isFastDeal = false;
    private boolean isVariations = false;
    public void setSeats(int seats) {
        this.seats = seats;
    }

    public void setDecks(int decks) {
        this.decks = decks;
    }

    public void setFastDeal(boolean isFastDeal) {
        this.isFastDeal = isFastDeal;
    }

    public void setVariations(boolean isVariations) {
        this.isVariations = isVariations;
    }

    public void setDASallowed(boolean isDASallowed) {
        this.isDASallowed = isDASallowed;
    }

    public void setRSAallowed(boolean isRSAallowed) {
        this.isRSAallowed = isRSAallowed;
    }

    public void setDLRhitSoft17(boolean isDLRhitSoft17) {
        this.isDLRhitSoft17 = isDLRhitSoft17;
    }

    public void setEuropeanStyle(boolean isEuropeanStyle) {
        this.isEuropeanStyle = isEuropeanStyle;
    }

    public void setLateSurrenderAllowed(boolean isLateSurrenderAllowed) {
        this.isLateSurrenderAllowed = isLateSurrenderAllowed;
    }

    public void setBlackjack6to5(boolean isBlackjack6to5) {
        this.isBlackjack6to5 = isBlackjack6to5;
    }

    private boolean isDASallowed = true;
    private boolean isRSAallowed = true;
    private boolean isDLRhitSoft17 = true;
    private boolean isEuropeanStyle = false;
    private boolean isLateSurrenderAllowed = false;
    private boolean isBlackjack6to5 = false;

    @Override
    public int getSeats() {
        return seats;
    }

    @Override
    public int getDecks() {
        return decks;
    }

    /**
     * Default is false.
     */
    @Override
    public boolean isFastDeal() {
        return isFastDeal;
    }

    /**
     * Default is false.
     */
    @Override
    public boolean isBasicStrategyVariationsOnly() {
        return isVariations;
    }

    /**
     * Default is true.
     */
    @Override
    public boolean isDoubleAfterSplitAllowed() {
        return isDASallowed;
    }

    /**
     * Default is true.
     */
    @Override
    public boolean isResplitAcesAllowed() {
        return isRSAallowed;
    }

    private List<String> sd;

    @Override
    public List<String> getStrategyData() {
        if (sd == null) {
            try {
                sd = RezIO.loadLinesFromResource(DEFAULT_STRATEGY_RSRC, this.getClass());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return sd;
    }

    @Override
    public CountingSystems getCountingSystems() {
        if (cs == null) {
            try {
                cs = new CountingSystems(
                        RezIO.loadLinesFromResource(DEFAULT_COUNTING_SYSTEMS_RSRC, this.getClass()));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return cs;
    }

    private CountingSystems cs;

    public static final String REZ_PATH

    = "/com/panopset/game/blackjack/";

    public static final String DEFAULT_STRATEGY_RSRC

    = REZ_PATH + "basic.txt";

    public static final String DEFAULT_COUNTING_SYSTEMS_RSRC

    = REZ_PATH + "cs.txt";

    @Override
    public int getWagerIncrement() {
        return DEFAULT_INITIAL_WAGER;
    }

    @Override
    public String getRawReloadAmountFromConfig() {
        return new DollarConverter().int2str(DEFAULT_INITIAL_STAKE);
    }

    @Override
    public boolean isDealerHitSoft17() {
        return isDLRhitSoft17;
    }

    @Override
    public boolean isCountVeryPositive() {
        return false;
    }

    @Override
    public boolean isEuropeanStyle() {
        return isEuropeanStyle;
    }

    @Override
    public boolean isCountVeryNegative() {
        return false;
    }

    @Override
    public String getStackedDeck() {
        return "";
    }

    @Override
    public String getWonMsg() {
        return "Won";
    }

    @Override
    public String getLostMsg() {
        return "Lost";
    }

    @Override
    public String getPushMsg() {
        return "Push";
    }

    @Override
    public String getBlackjackMsg() {
        return "Blackjack";
    }

    @Override
    public String getBustedMsg() {
        return "Busted";
    }

    @Override
    public String getHandNotActiveMsg() {
        return "Hand is not active.";
    }

    @Override
    public String getHandNotDealtMsg() {
        return "Hand has not been dealt yet.";
    }

    @Override
    public String getDoubleImpossibleMsg() {
        return "Double not possible here.";
    }

    @Override
    public String getHandActiveMsg() {
        return "Hand is still active";
    }

    @Override
    public String getShuffledMsg() {
        return "Shuffled";
    }

    @Override
    public String getPleaseSelectMsg() {
        return "Please select";
    }

    @Override
    public String getDealMsg() {
        return "Deal";
    }

    @Override
    public boolean isLateSurrenderAllowed() {
        return isLateSurrenderAllowed;
    }

    @Override
    public String getResetMsg() {
        return "Reset";
    }

    @Override
    public boolean isBlackjack6to5() {
        return isBlackjack6to5;
    }

    @Override
    public int getLargeBet() {
        return DEFAULT_LARGE_BET;
    }

    @Override
    public int getTargetStake() {
        return DEFAULT_TARGET_STAKE;
    }

    @Override
    public boolean isShowCount() {
        return true;
    }

    @Override
    public void toggleShowCount() {
        // default doesn't do anything.
    }

    @Override
    public ScreenSizer getScreenSizer() {
        return ScreenSizer.SMALL;
    }
}
